package com.zzh.takeoutapp.adapter;


import android.support.annotation.Nullable;
import android.util.Log;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zzh.takeoutapp.R;
import com.zzh.takeoutapp.entity.FoodBean;
import com.zzh.takeoutapp.view.goods.AddWidget;

import java.math.BigDecimal;
import java.util.List;

public class CarAdapter extends BaseQuickAdapter<FoodBean, BaseViewHolder> {
    private AddWidget.OnAddClick onAddClick;
    private List<FoodBean> data;


    public CarAdapter(@Nullable List<FoodBean> data, AddWidget.OnAddClick onAddClick) {
        super(R.layout.item_car, data);
        this.onAddClick = onAddClick;
        this.data = data;
    }

    @Override
    protected void convert(BaseViewHolder helper, FoodBean item) {
        Log.e("addUserDialogFragment", item.getName() + "========" + item.getProduct_id());
        helper.setText(R.id.car_name, item.getName())
                .setText(R.id.car_price,
                        item.getStrPrice(mContext,
                                item.getPrice().multiply(BigDecimal.valueOf(item.getSelectCount()))));
        AddWidget addWidget = helper.getView(R.id.car_addwidget);
        addWidget.setData(this, onAddClick, data, item);
    }
}
